package day01;

import java.util.Arrays;

/**
 * @author feng
 * @Date 2021/9/22 7:44
 */
public class SearchArray {
    public static void main(String[] args) {
        int[] a1 = {1,5,50,40,15};
        Arrays.sort(a1);
        //fan'hu
        int i = Arrays.binarySearch(a1,50);
        System.out.println(i);
        System.out.println("--------------");
//        int[] array = Arrays.copyOf(a1,5);
//        for (int j = 0; j <array.length ; j++) {
//            System.out.println(array[j]);
//        }
//        System.out.println("------");
        int[] a2 = Arrays.copyOfRange(a1,0,3);
        for (int j = 0; j <a2.length ; j++) {
            System.out.println(a2[j]);
        }
    }
}
